package iad.parser;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.ArrayList;
import java.util.List;

public class AbaloneParser {

	public static void parse(File f){

		try
		{
			FileInputStream fstream = new FileInputStream(f.getName());
			// Get the object of DataInputStream
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;

			String[] tab;

			List<Attribute> firstAttributeList = new ArrayList<Attribute>();
			List<Attribute> secondAttributeList = new ArrayList<Attribute>();
			List<Attribute> thirdAttributeList = new ArrayList<Attribute>();
			List<Attribute> fourthAttributeList = new ArrayList<Attribute>();
			List<Attribute> fifthAttributeList = new ArrayList<Attribute>();
			List<Attribute> sixthAttributeList = new ArrayList<Attribute>();
			List<Attribute> seventhAttributeList = new ArrayList<Attribute>();
			List<Attribute> eighthAttributeList = new ArrayList<Attribute>();

			//Read File Line By Line
			while ((strLine = br.readLine()) != null){

//				Attribute firstAttribute = new Attribute();
//				Attribute secondAttribute = new Attribute();
//				Attribute thirdAttribute = new Attribute();
//				Attribute fourthAttribute = new Attribute();
//				Attribute fifthAttribute = new Attribute();
//				Attribute sixthAttribute = new Attribute();
//				Attribute seventhAttribute = new Attribute();
//				Attribute eighthAttribute = new Attribute();

				// Print the content on the console
				//System.out.println (strLine);
				tab=strLine.split(",");

				//tu musze z tablicy przepisac przeparsowac do odpowiedniego atrybutu


				//				firstAttribute.set tab[0];   //bo to nazwa i dobrze ze jest stringiem
				//				secondAttribute.set Double.parseDouble(tab[1]);
				//				thirdAttribute.set Double.parseDouble(tab[2]);
				//				fourthAttribute.set Double.parseDouble(tab[3]);
				//				fifthAttribute.set Double.parseDouble(tab[4]);
				//				sixthAttribute.set Double.parseDouble(tab[5]);
				//				seventhAttribute.set Double.parseDouble(tab[6]);
				//				eightthAttribute.set Integer.parseInt(tab[7]);

//				firstAttributeList.add(firstAttribute);
//				secondAttributeList.add(secondAttribute);
//				thirdAttributeList.add(thirdAttribute);
//				fourthAttributeList.add(fourthAttribute);
//				fifthAttributeList.add(fifthAttribute);
//				sixthAttributeList.add(sixthAttribute);
//				seventhAttributeList.add(seventhAttribute);
//				eighthAttributeList.add(eighthAttribute);

			}
			//Close the input stream
			in.close();
		}
		catch (Exception e){//Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}

	}

}
